IF EXISTS (
       SELECT *
       FROM   sys.objects
       WHERE  OBJECT_ID = OBJECT_ID(N'[dbo].[cms_sp_PageSelectAllByTemplateId]')
              AND TYPE IN (N'P' ,N'PC')
   )
    DROP PROCEDURE [dbo].[cms_sp_PageSelectAllByTemplateId]
GO

CREATE PROCEDURE [dbo].[cms_sp_PageSelectAllByTemplateId]
(@TemplateId INT)
AS
	SELECT *
	FROM   Pages AS p
	WHERE  p.TemplateId = @TemplateId
GO